COMMON = stream.o sized_io.o
OFILES = $(COMMON) reader.o writer.o
#HFILES = inet.h
HFILES = inet.h nntpclnt.h nntp.h

# disable -mc68020 flag with following
##TARGET_ARCH=

# set for the OS you are compiling for.  Due to incompatibility with
# <netdb.h>, it is impossible to produce object files from one OS that
# link with another.  Specifically, it is the change in hostent which
# occurred transitioning from 3.0 to 4.0.
# OS=4.0

#FD_SET_SIZE = set to 32 if old-style, otherwise comment out
# Sun
##CFLAGS = -mc68010 -g -Bstatic -DFD_SET_SIZE=32

# choose any of the following as appropriate
#CFLAGS = -mc68010 -g -DDEBUG -DFD_SET_SIZE=32
# Silicon Graphics
##CFLAGS = -I/usr/include/bsd -DFD_SET_SIZE=32

##LFLAGS = -Bstatic -L/lib.MC68010 -L/usr.MC68010/lib

# Sun
#LIB = libstream$(OS).a
#LIB = libinfo2-$(ARCH).a
# Silicon Graphics
#LIB = libstream$(OS).a -lbsd

# bsd/os
LIB = libstream$(OS).a 

# if you don't need to do ranlib (i.e. SV, Silicon Graphics)
# change following to "RANLIB = echo"
RANLIB = echo

# for testing purposes

all:	$(LIB)

test: $(LIB) reader writer reader-auto writer-auto

OBJS = stream.o sized_io.o fdopen2.o nntpclnt.o

$(LIB): $(OBJS)
	ar cr $(LIB)  `lorder $(OBJS) | tsort` 
	$(RANLIB) $(LIB)

cleanup:
	rm $(OFILES) $(LIB)

install: $(LIB) 
	cp $(HFILES) /usr/open/classes/slab/info2/include
	cp $(LIB)  /usr/open/classes/slab/info2/lib
	$(RANLIB) /usr/open/classes/slab/info2/lib/$(LIB)
#	cp stream.3 /usr/local/man/manl/sized_io.l
	nroff -man stream.3 > /usr/open/classes/slab/info2/lib/initport.doc
	cp nntpclnt.c /usr/open/classes/slab/info2/lib

nntpclnt.o: nntpclnt.c nntpclnt.h nntp.h


makedirs: /usr/local/include/inet /usr/local/include/inet/stream

/usr/local/include/inet:
	mkdir /usr/local/include/inet

/usr/local/include/inet/stream:
	mkdir /usr/local/include/inet/stream

lint:
	lint -u stream.c sized_io.c

lintc:
	lint -Cstream stream.c sized_io.c
	# must be su to execute rest of this
	mv llib-lstream.ln /usr/lib/lint
	chown libes /usr/lib/lint/llib-lstream.ln

stream.o: inet.h

reader: reader.o $(COMMON) inet.h
	cc $(LFLAGS) -o reader reader.o $(LIB)

writer:	writer.o $(COMMON) inet.h
	cc $(LFLAGS) -o writer writer.o $(LIB)

reader-auto: reader-auto.o $(COMMON) inet.h
	cc $(LFLAGS) -o reader-auto reader-auto.o $(LIB)

writer-auto:	writer-auto.o $(COMMON) inet.h
	cc $(LFLAGS) -o writer-auto writer-auto.o $(LIB)

ftp:	sized_io.shar.Z
	rcp sized_io.shar.Z durer:~ftp/pub/sized_io.shar.Z
	rm sized_io.shar.Z

sized_io.shar.Z:	sized_io.shar
	compress sized_io.shar

sized_io.shar:
	shar Makefile README sized_io.ps inet.h reader-auto.c reader.c sized_io.c stream.3 stream.c writer-auto.c writer.c > sized_io.shar
